package fivm.cross.platform.steamobj.controller;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import fivm.cross.platform.ficommon.distinguish.FiObjectId;
import fivm.cross.platform.ficommon.distinguish.GsonSimpleSerializable;

/**
 * Created by Administrator on 2016/5/17.
 * 所有对手机的主控操作
 * 主要通过脚本对手机的控制
 */
public class CommandStream extends GsonSimpleSerializable{
    @Expose @SerializedName("_id")
    private FiObjectId id=FiObjectId.NewNull;
    @Expose @SerializedName("ActionName")
    private String actionName="";      //操作名称，比如注入zygote，重启zygote，

    public final static int SHELL_CARRIER_FILE=0;
    public final static int SHELL_CARRIER_MSG=1;


    @Expose @SerializedName("Carrier")
    private int carrier=SHELL_CARRIER_MSG;         //运行的载体类型，主要有shell文件，或者直接就是发字符串下去
    @Expose @SerializedName("CmdsMsg")
    private String cmds="";             //如果仅仅就是一两行shell代码的处理。那么就直接发字符串下去操作算了
    @Expose @SerializedName("Shell")
    private String shell="";            //如果是文件shell，那我们要有一个启动文件的shell命令
    @Expose @SerializedName("ServerFilePath")
    private String serverFilePath="";  //操作脚本文件的服务端路径
    @Expose @SerializedName("ClientFilePath")
    private String clientFilePath="";  //操作脚本文件的客户端路径
    @Expose @SerializedName("RunEnvironment")
    private String runEnvironment="all";  //运行的环境，目前定义all,linux,zygote,app,activity

    
    /**
     * 产生一个简单的字符串命令操作
     * */
    public static CommandStream genSimpleCmdMsg(String actionName,String cmdsMsg){
        CommandStream cmdStream=new CommandStream();
        cmdStream.setId(new FiObjectId());
        cmdStream.setActionName(actionName);
        cmdStream.setCarrier(SHELL_CARRIER_MSG);
        cmdStream.setCmds(cmdsMsg);
        return cmdStream;
    }


    public FiObjectId getId() {
        return id;
    }

    public void setId(FiObjectId id) {
        this.id = id;
    }

    public String getActionName() {
        return actionName;
    }

    public void setActionName(String actionName) {
        this.actionName = actionName;
    }

    public int getCarrier() {
        return carrier;
    }

    public void setCarrier(int carrier) {
        this.carrier = carrier;
    }

    public String getCmds() {
        return cmds;
    }

    public void setCmds(String cmds) {
        this.cmds = cmds;
    }

    public String getServerFilePath() {
        return serverFilePath;
    }

    public void setServerFilePath(String serverFilePath) {
        this.serverFilePath = serverFilePath;
    }

    public String getClientFilePath() {
        return clientFilePath;
    }

    public void setClientFilePath(String clientFilePath) {
        this.clientFilePath = clientFilePath;
    }

    public String getRunEnvironment() {
        return runEnvironment;
    }

    public void setRunEnvironment(String runEnvironment) {
        this.runEnvironment = runEnvironment;
    }

    public String getShell() {
        if(shell==null || shell.equals("")){
            shell=this.getClientFilePath();
            //this.setShell(shell);
        }
        return shell;
    }

    public void setShell(String shell) {
        this.shell = shell;
    }
}
